package dongshi.daddy.huohuo;

import java.util.concurrent.TimeUnit;

public class SynchronizedLockMain {

    private static Object lock1 = new Object();
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> SynchronizedLockMain.m1(), "线程1号");
        t1.start();

        Thread t2 = new Thread(() -> SynchronizedLockMain.m1(), "线程2号");
        t2.start();

        // 中断被lockInterruptibly方法阻塞的线程2
         t2.interrupt();
    }

    private static void m1() {
        synchronized (lock1) {
            try {
                TimeUnit.SECONDS.sleep(300000);
            } catch (InterruptedException e) {
                System.out.println(Thread.currentThread().getName() + " is interrupted!!!");
            }
        }
    }
}
